
package com.joysuch.wwyt.bp.enums;

public enum SafetyWorkStates {

    INITIAL(0, "待申请"),
    WAITING_FOR_AUDIT(1, "待审核"),
    AUDIT_SUCCESS(2, "待签批"),
    AUDIT_FAILED(3, "审核未通过"),
    CHECK_ACCEPTED(4,"验收通过"),
    CHECK_FAILED(5,"验收不通过"),
    IN_WORK(6,"作业中");

    private int id;
    private String name;

    private SafetyWorkStates(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static SafetyWorkStates findByName(String name) {
        SafetyWorkStates[] values = SafetyWorkStates.values();
        for (SafetyWorkStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static SafetyWorkStates findById(Integer level) {
        SafetyWorkStates[] values = SafetyWorkStates.values();
        for (SafetyWorkStates v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        SafetyWorkStates[] values = SafetyWorkStates.values();
        for (SafetyWorkStates v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
